// This function processes the quiz data
function assessment()
{
	var ft = sessionStorage.getItem( "firstTime" );
	
	if( ft == null )
	{
	sessionStorage.setItem( "visitModule1", "0" );
	sessionStorage.setItem( "visitModule2", "0" );
	sessionStorage.setItem( "visitModule3", "0" );
	sessionStorage.setItem( "visitModule4", "0" );
	sessionStorage.setItem( "firstTime", "1" );
	}
	visitModule1();
}

function visitModule1()
{
	sessionStorage.setItem( "visitModule1", "1" );
	showAssessment();
}

function visitModule2()
{
	sessionStorage.setItem( "visitModule2", "1" );
	showAssessment();
}

function visitModule3()
{
	sessionStorage.setItem( "visitModule3", "1" );
	showAssessment();
}

function visitModule4()
{
	sessionStorage.setItem( "visitModule4", "1" );
	showAssessment();
}

function showAssessment()
{
	var vi = sessionStorage.getItem( "visitModule1" );
	var vp2 = sessionStorage.getItem( "visitModule2" );
	var vp3 = sessionStorage.getItem( "visitModule3" );
	var vp4 = sessionStorage.getItem( "visitModule4" );

	
	if( vi == "1" && vp2 == "1" && vp3 == "1" && vp4 == "1" )
	{
		//show assessment link
		document.getElementById( "assessmentlink" ).style.display = "inline";
	}	
}

function submitAssessment()
{
	var q1 = document.forms.assessment.question1;
	var q2 = document.forms.assessment.question2;
	var q3 = document.forms.assessment.question3;
	var q4 = document.forms.assessment.question4;
	var q5 = document.forms.assessment.question5;
	var q6 = document.forms.assessment.question6;
	var q7 = document.forms.assessment.question7;
	var q8 = document.forms.assessment.question8;
	var q9 = document.forms.assessment.question9;
	var q10 = document.forms.assessment.question10;
	
	if( q1[ 0 ].checked == true && q2[ 2 ].checked == true && 
		q3[ 0 ].checked == true && q4[ 2 ].checked == true &&
		q5[ 1 ].checked == true && q6[ 1 ].checked == true &&
		q7[ 0 ].checked == true && q8[ 1 ].checked == true &&
		q9[ 1 ].checked == true && q10[ 0 ].checked == true )
	{
		alert( "Congratulations, you are a car buying expert!" );
	}
	else
	{
		alert( "You are almost a car buying expert, please try again." );
	}
	
	// call the function to report score
	parent.reportScores();
	
}